# -*- coding: UTF-8 -*-
import requests;
import cookielib
from bs4 import BeautifulSoup
import re

session=requests.session();
session.cookies=cookielib.LWPCookieJar("cookies")
session.cookies.load("cookies")
session.proxies={"127.0.0.1:88888"}
def get(page, content):
    startUrl="http://weibo.cn/u/2706748591?vt=4"
    if page > 1:
        startUrl = "http://weibo.cn/u/2706748591?page=" +str(page)+ "&vt=4"
    wb=session.get(startUrl)
    r=BeautifulSoup(wb.text, "html.parser")
    divs=r.findAll("div", {"class":"c", "id":re.compile("M_(\w)?")})
    for div in divs:
        #print div.find("span", {"class":"ctt"}).text
        href=div.find("a", {"class":"cc"})['href']
        detail=session.get(href).text
        doc=BeautifulSoup(detail, "html.parser")
        postUrl=doc.find("form")['action'];
        postData={
                  "srcuid":doc.find("input", {"name":"srcuid"})['value'],
                  "id":doc.find("input", {"name":"id"})['value'],
                  "rl":doc.find("input", {"name":"rl"})['value'],
                  "content":content
                  }
        result=session.post("http://weibo.cn"+postUrl, data=postData)
        print result.status_code
get(1, "我真的想不明白啊")